home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d13 / pctv2n2.arc / HPFONT.HPP < prev    next >
C/C++ Source or Header  |  1991-08-11  |  4KB  |  108 lines

  1. //-------------------------------------------------------------//
  2. // File:   HpFont.Hpp                                          //
  3. // Desc:   Definition for an HP Soft Font Class                //
  4. // Author: Marv Luse, Autumn Hill Software                     //
  5. //-------------------------------------------------------------//
  6.  
  7. #ifndef _HPFONT_HPP_
  8. #define _HPFONT_HPP_
  9.  
  10. #include "Font.Hpp"
  11.  
  12. //........ macro to swap bytes in a 2-byte word
  13.  
  14. #define REV_WRD( w )  ( ((w>>8) & 0x00FF) | (w<<8) )
  15.  
  16. //........ constants for categorizing escape sequences
  17.  
  18. const int eFONTDESC = 1;        // define font descriptor
  19. const int eCHARDESC = 2;        // define char descriptor
  20. const int eCHARCODE = 3;        // specify current char code
  21. const int eUNKNOWN  = 4;        // anything else
  22.  
  23. //........ constants indicating HP font status
  24.  
  25. const int hpNOINIT    = 0;      // uninitialized font
  26. const int hpOKAY      = 1;      // all is well
  27. const int hpNOTFOUND  = 101;    // disk file not found
  28. const int hpIOERROR   = 102;    // io error, unexpected eof, etc.
  29. const int hpBADFMT    = 103;    // format failure
  30. const int hpOVRFLOW   = 104;    // internal buffer overflow
  31. const int hpNOMEM     = 105;    // memory allocation failed
  32.  
  33. //........ font descriptor data structure
  34.  
  35. struct font_desc
  36. {
  37.     unsigned int   fd_size;        // font descriptor size
  38.              char  resv_1;         // reserved
  39.     unsigned char  font_type;      // font type
  40.              int   resv_2;         // reserved
  41.     unsigned int   bl_dist;        // baseline dist (D)
  42.     unsigned int   cell_width;     // cell width (D)
  43.     unsigned int   cell_height;    // cell height (D)
  44.     unsigned char  orient;         // orientation
  45.     unsigned char  proportional;   // 0=fixed, 1=proportional
  46.     unsigned int   sym_set;        // symbol set
  47.     unsigned int   pitch;          // pitch (QD)
  48.     unsigned int   height;         // height (QD)
  49.     unsigned int   xheight;        // x height (QD)
  50.              char  wid_typ;        // width type
  51.     unsigned char  style;          // style
  52.              char  stroke_weight;  // stroke weight
  53.     unsigned char  typeface;       // typeface
  54.              char  resv_3;         // reserved
  55.     unsigned char  serif_style;    // serif style
  56.              int   resv_4;         // reserved
  57.              char  ul_dist;        // underline dist (D)
  58.     unsigned char  ul_height;      // underline height (D)
  59.     unsigned int   txt_height;     // text height (QD)
  60.     unsigned int   txt_width;      // text width  (QD)
  61.              int   resv_5;         // reserved
  62.              int   resv_6;         // reserved
  63.     unsigned char  pitch_ext;      // pitch extended  (D/1024)
  64.     unsigned char  height_ext;     // height extended (D/1024)
  65.              int   resv_7;         // reserved
  66.              int   resv_8;         // reserved
  67.              int   resv_9;         // reserved
  68.              char  font_name[16];  // font name
  69. };
  70.  
  71. //........ character descriptor data structure
  72.  
  73. struct char_desc
  74. {
  75.     unsigned char  format;         // 4 for LaserJet family
  76.              char  continue_flag;  // 0 normally
  77.     unsigned char  desc_size;      // 14 for LaserJet family
  78.     unsigned char  desc_class;     // 1=bitmap, 2=compressed
  79.     unsigned char  orient;         // should match font_dec
  80.              char  resv_1;         // reserved
  81.              int   left_ofs;       // ref pt to bm left (D)
  82.              int   top_ofs;        // ref pt to bm top  (D)
  83.     unsigned int   char_width;     // bitmap width in pixels
  84.     unsigned int   char_height;    // bitmap height in pixels
  85.              int   delta_x;        // ref pt delta (QD)
  86.     //............................... bitmap data follows here
  87. };
  88.  
  89. //........ HP Soft Font Class
  90.  
  91. class HpFont : public Font
  92. {
  93.    public:
  94.  
  95.       int hpstatus;
  96.  
  97.       HpFont( );
  98.       HpFont( char *path );
  99.      ~HpFont( );
  100.  
  101.    private:
  102.  
  103.       void SetFontMetrics( font_desc& fd );
  104.       void SetCharMetrics( Character&, char_desc& fc );
  105. };
  106.  
  107. #endif
  108.